

<%@page import="java.util.List"%>
<%@page import="Bean.Profesor"%>
<%@page import="java.util.ArrayList"%>
<%-- 
    Document   : index
    Created on : 11/06/2013, 12:22:01 PM
    Author     : Angel
--%>
<%@page import="Bean.Usuario"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">


<!DOCTYPE html>
<%
    String context = request.getContextPath();
    HttpSession sesion = request.getSession();
        List<Profesor> list = new ArrayList<Profesor>();
    
    list = (ArrayList<Profesor>) request.getAttribute("lista");
    Profesor prof=(Profesor)request.getAttribute("profesor");
    Usuario login = new Usuario();
    if (sesion.getAttribute("login") == null) {
        response.sendRedirect(context + "/ServletLogin");
    } else {
        login = (Usuario) sesion.getAttribute("login");
    }
%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
    <head>
        <!--  Created by Artisteer v3.0.0.32906  Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"  -->
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <%=request.getContextPath()%>
        <title>Sistema de Control de Reservaciones CCS</title>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css" type="text/css" media="screen" />
<!--        <link href="<%=request.getContextPath()%>/menu_assets/styles.css" rel="stylesheet" type="text/css">-->

        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/script.js"></script>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/jquery.ui.all.css">
        <script src="<%=request.getContextPath()%>/js/jquery-1.9.1.js"></script>
        <script src="<%=request.getContextPath()%>/js//jquery.ui.core.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.widget.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.dialog.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.button.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.mouse.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.draggable.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.position.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.resizable.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.effect.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.effect-fade.js"></script>
        <script src="<%=request.getContextPath()%>/js/jquery.ui.effect-blind.js"></script>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/demos.css">
        <link rel="stylesheet" href="<%=request.getContextPath()%>/css/menu.css">
        <style>
            body { font-size: 62.5%; }
            label, input { display:block; }
            input.text { margin-bottom:12px; width:95%; padding: .4em; }
            fieldset { padding:0; border:0; margin-top:25px; }
            h1 { font-size: 1.2em; margin: .6em 0; }
            div#users-contain { width: 350px; margin: 20px 0; }
            div#users-contain table { margin: 1em 0; border-collapse: collapse; width: 80%; }
            div#users-contain table td, div#users-contain table th { border: 1px solid #eee; padding: .6em 10px; text-align: left; }
            .ui-dialog .ui-state-error { padding: .3em; }
            .validateTips { border: 1px solid transparent; padding: 0.3em; }
        </style>
        <script>
            $(function() {
		$( "input[type=submit],button" )
			.button()
			.click(function( event ) {
				event.preventDefault();
			});
	});
            $(function() {
                
		$( " button" )
			.button()
			.click(function( event ) {
				event.preventDefault();
			});

                var nombre = $( "#nombre" ),
                email = $( "#email" ),
                telefono=$("#telefono"),
                apaterno=$("#apaterno"),
                amaterno=$("#amaterno"),
                celular=$("#celular"),
                direccion=$("#direccion"),id=("#id")
//                password = $( "#password" ),
                allFields = $( [] ).add( nombre ).add( email ).add(telefono).add(apaterno).add(amaterno).add(celular).add(direccion).add(id)
                
                tips = $( ".validateTips" );

                function updateTips( t ) {
                    tips
                    .text( t )
                    .addClass( "ui-state-highlight" );
                    setTimeout(function() {
                        tips.removeClass( "ui-state-highlight", 1500 );
                    }, 500 );
                }

                function checkLength( o, n, min, max ) {
                    if ( o.val().length > max || o.val().length < min ) {
                        o.addClass( "ui-state-error" );
                        updateTips( "El tamaño de " + n + " debe estar entre " +
                            min + " y " + max + "." );
                        return false;
                    } else {
                        return true;
                    }
                }

                function checkRegexp( o, regexp, n ) {
                    if ( !( regexp.test( o.val() ) ) ) {
                        o.addClass( "ui-state-error" );
                        updateTips( n );

                        return false;
                    } else {
                        return true;
                    }
                }

                $( "#dialog-form" ).dialog({
                    show: {

				effect: "blind",
				duration: 1000
			},
			
                    autoOpen: true,
                    height: 500,
                    width: 350,
                    modal: true,
                    buttons: {
                        "Crear": function() {
                            var bValid = true;
                            allFields.removeClass( "ui-state-error" );

                            bValid = bValid && checkLength( nombre, "nombre de profesor", 3, 16 );
                            bValid = bValid && checkLength( email, "email", 6, 80 );
                            bValid = bValid && checkLength( telefono, "telefono", 0, 10 );
                            bValid = bValid && checkLength( celular, "celular", 0, 10 );
                            bValid = bValid && checkLength( apaterno, "apellido paterno", 0, 25 );
                            bValid = bValid && checkLength( amaterno, "apellido materno", 0, 25 );
                            bValid = bValid && checkLength( direccion, "direccion", 0, 60 );
//                            bValid = bValid && checkLength( password, "password", 5, 16 );
                            bValid = bValid && checkRegexp( telefono, /^[0-9]+$/i, "Telefono debe contener solo numeros." );
                            bValid = bValid && checkRegexp( celular, /^[0-9]+$/i, "Celular debe contener solo numeros." );
//                            bValid = bValid && checkRegexp( nombre, /^[a-z]([0-9a-z ])+$/i, "Username may consist of a-z, 0-9, underscores, begin with a letter." );
                            // From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
                            bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. ui@jquery.com" );
//                            bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );

                            if ( bValid ) {
//                                $( this ).dialog( "close" );
//                                $( "#users tbody" ).append( "<tr>" +
//                                    "<td>" + name.val() + "</td>" +
//                                    "<td>" + email.val() + "</td>" +
//                                    "<td>" + password.val() + "</td>" +
//                                    "</tr>" );
                                            $( this ).dialog( "close" );
                                $('#insertar').submit();
                            }
                        },
                        Cancelar: function() {
                            allFields.val( "" ).removeClass( "ui-state-error" );
                            $( this ).dialog( "close" );
                        }
                    },
                    close: function() {
                        
                        
                        effect: "explode"
                    }
                });

                $( "#create-user" )
                .button()
                .click(function() {

                        var nombre = $( "#nombre" ),
                email = $( "#email" ),
                telefono=$("#telefono"),
                apaterno=$("#apaterno"),
                amaterno=$("#amaterno"),
                celular=$("#celular"),
                direccion=$("#direccion"),

//                password = $( "#password" ),
                allFields = $( [] ).add( nombre ).add( email ).add(telefono).add(apaterno).add(amaterno).add(celular).add(direccion)
                    allFields.val( "" ).removeClass( "ui-state-error" );
                    $("#apaterno").val("");
                    $( "#dialog-form" ).dialog( "open" );
                });
                $( "#editar" )
                .button()
                .click(function() {
                    
                    $( "#dialog-form" ).dialog( "open" );
                });
            });
        </script>
    </head>
    <body >



        <div id="art-page-background-glare">
            <div id="art-page-background-glare-image">
                <div id="art-main">
                    <div class="art-sheet">

                        <div class="art-sheet-body">
                            <div class="art-header">
                                <div class="art-header-center">
                                    <div class="art-header-png"></div>
                                    <div class="art-header-jpeg"></div>
                                </div>
                                <div class="art-logo">
                                    <h1 id="name-text" class="art-logo-name"><a href="../index.html"></a></h1>
                                    <h2 id="slogan-text" class="art-logo-text"></h2>
                                </div>
                            </div>
                            <div class="art-nav">
                                <div class="l"></div>
                                <div class="r"></div>
                                <ul class="art-menu">
                                </ul>
                            </div>
                            <div class="art-content-layout">
                                 <div id='cssmenu'>
                                    <ul>
                                       <li class='active'><a href='<%=context%>index.jsp'><span>Inicio</span></a></li>
                                       <li class='has-sub'><a href='<%=context%>/ControladorDispositivos?accion=Consultar'><span>Equipo</span></a></li>
                                       <li class='has-sub'><a href='#'><span>Aulas</span></a></li>
                                       <li class='has-sub'><a href='#'><span>Reservaciones</span></a></li>
                                       <li class='has-sub'><a href="<%=context%>/ControladorProfesor?accion=Consultar"><span>Profesores</span></a></li>

                                    </ul>
                                    </div>
                                <div class="art-content-layout-row">
<!--                                    <div class="art-layout-cell art-sidebar1">-->
<!--                                        <div id='cssmenu'>
                                            <ul>
                                                <li class='active'><a href='#'><span>Usuarios</span></a></li>
                                                <li><a href='#'><span>Equipo</span></a></li>
                                                <li><a href='#'><span>Aulas</span></a></li>
                                                <li><a href='#'><span>Reservaciones</span></a></li>
                                                <li><a href='#'><span>Profesores</span></a></li>
                                                <li><a href='#'><span>seis</span></a></li>
                                            </ul>
                                        </div>-->



<!--                                    </div>-->
                                    <div class="art-layout-cell art-content">
                                        <div class="art-post">
                                            <div class="art-post-body">
                                                <span class="art-button-wrapper" style="margin-left:800px; margin-top:10px;">
                                                    <span class="art-button-l"> </span><span class="art-button-r"> </span>
                                                    <a  class="art-button"  href="<%=context%>/ServletLogin?accion=cerrarSesion">Cerrar Sesión</a>
                                                </span>

                                                <div class="art-post-inner art-article">
                                                    <div class="art-postmetadataheader">

                                                        <h2 class="art-postheader">Modificar profesor</h2>
                                                    </div>
                                                    <div class="art-postcontent">
                                                        <div id="dialog-form" title="Modificar profesor">
                                                            <p class="validateTips">Todos los campos son requeridos.</p>
                                                            <form id="insertar" action="<%=context%>/ControladorProfesor?accion=Actualizar" method="post">
                                                                <fieldset>
                                                                    <input name="id" type="hidden" value="<%=prof.getId()%>" id="id">
                                                                    <label for="name">Nombre</label>
                                                                    <input type="text" name="nombre" value="<%=prof.getNombres()%>" id="nombre" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">apaterno</label>
                                                                    <input type="text" name="apaterno" value="<%=prof.getApaterno()%>" id="apaterno" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">amaterno</label>
                                                                    <input type="text" name="amaterno" value="<%=prof.getAmaterno()%>" id="amaterno" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">direccion</label>
                                                                    <input type="text" name="direccion" value="<%=prof.getDireccion()%>" id="direccion" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">Telefono</label>
                                                                    <input type="text" name="telefono" value="<%=prof.getTelefono()%>" id="telefono" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="name">Celular</label>
                                                                    <input type="text" name="celular" value="<%=prof.getCelular()%>"id="celular" class="text ui-widget-content ui-corner-all" />
                                                                    <label for="email">Correo</label>
                                                                    <input type="text" name="correo" value="<%=prof.getCorreo()%>" id="email" value="" class="text ui-widget-content ui-corner-all" />
<!--                                                                    <label for="password">Password</label>
                                                                    <input type="password" name="password" id="password" value="" class="text ui-widget-content ui-corner-all" />-->
                                                                </fieldset>
                                                            </form>
                                                        </div>
                                                        <div id="users-contain" class="ui-widget">
                                                            <table id="users" class="ui-widget ui-widget-content">
                                                                <thead>
                                                                    <tr class="ui-widget-header ">
                                                                        <th>Editar</th>
                                                                        <th>Nombre</th>
                                                                        <th>Paterno</th>
                                                                        <th>Materno</th>
                                                                        <th>Direccion</th>
                                                                        <th>Telefono</th>
                                                                        <th>Celular</th>
                                                                        <th>Correo</th>
                                                                        <th>Eliminar</th>
                                                                    </tr>
                                                                </thead>
                                                                <tbody>
                                                                    <%for (Profesor profesor : list) {%>
                                                                    <tr>
                                                                        <td id="<%=profesor.getId()%>" onclick="editar(this.id);">
                                                                            <button id="editar">Editar</button>
<!--                                                                            <input type="submit" value="A submit button">
                                                                            <button  id="algo<%=prof.getId()%>">Editar</button>-->
<!--                                                                            editar-->
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getNombres()%>
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getApaterno()%>
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getAmaterno()%>
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getDireccion()%>
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getTelefono()%>
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getCelular()%>
                                                                        </td>
                                                                        <td>
                                                                            <%=profesor.getCorreo()%>
                                                                        </td>
                                                                        <td id="<%=profesor.getId()%>" onclick="eliminar(this.id);">
                                                                            <button>Eliminar</button>
                                                                        </td>
                                                                        <%}%>
                                                                    </tr>

                                                                </tbody>
                                                            </table>
                                                                    <button id="create-user" >Agregar profesor</button>
                                                        </div>
                                                        <form id="uno" name="uno" action="<%=context%>/ControladorProfesor" metod="post">
                                                            <input type="hidden" value="" id="id" name="id"/>
                                                            <input type="hidden" value="" id="accion" name="accion"/>
                                                        </form>

                                                    </div>
                                                    <div class="cleared"></div>
                                                </div>
                                                <div class="cleared"></div>
                                            </div>
                                        </div>
                                        <div class="cleared"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="cleared"></div>
                            <div class="art-footer">
                                <div class="art-footer-t"></div>
                                <div class="art-footer-l"></div>
                                <div class="art-footer-b"></div>
                                <div class="art-footer-r"></div>
                                <div class="art-footer-body">
                                    <div class="art-footer-text">

                                        <p>Universidad Tecnològica Emiliano Zapata Av.Universidad Tecnològica No.1, Col. Palo Escrito, C.P.62760, Emiliano Zapata, Morelos.</p>
                                        <p>Tel.(01777) 368-11-65 Ext.270 jonathanaguilar@utez.edu</p>
                                    </div>
                                    <div class="cleared"></div>
                                </div>
                            </div>
                            <div class="cleared"></div>
                        </div>
                    </div>
                    <div class="cleared"></div>

                </div>
            </div>
        </div>

    </body>
</html>
<script id="scriptInit" type="text/javascript">
 
    
    //    $(document).ready(function () {
    //        $("#demo").wijgrid({
    //            allowSorting: true,
    //            allowPaging: true,
    //            pageSize: 15,
    //            columns: [
    //                { headerText: "Nombres" }, 
    //                { headerText: "Apellido paterno" }, 
    //                {headerText: "Apellido materno" }, 
    //                { headerText: "Direccion" }
    //            ]
    //        });
    //    });
    function editar(id){
        document.getElementById("id").value=id;
        document.getElementById("accion").value="Editar";

        document.uno.submit();
    }
    function eliminar(id)
    {
        document.getElementById("id").value=id;
        document.getElementById("accion").value="Eliminar";

        document.uno.submit();

    }
</script>
